<template>
	<view>
		<view class="bj"></view>
		<view class="main">
			<view class="nav1">

				<view class="logs">
					<image src="../../static/logo.png" mode=""></image>
					<u-icon label="" size="40" name="attach"></u-icon>
					<image src="../../static/wechat.png" mode=""></image>
				</view>

				<view class="text1">
					小竹财税账号绑定成功
				</view>
				<view class="text2">
					小竹财税账号：{{username}}
				</view>
				<view class="text3" @click="showUnbindAccount">
					解除绑定
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import request from "@/api/http.js"
	export default {
		data() {
			return {
				official_openid: '',
				username: ''
			};
		},
		onLoad() {
			this.official_openid = uni.getStorageSync('official_openid')
			this.username = uni.getStorageSync('username')

		},
		methods: {
			showUnbindAccount() {
				let that = this
				uni.showModal({
					title: '提示',
					content: '确定解除绑定',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							
							that.unbindAccount()
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},

			async unbindAccount() {
				const res = await request('/api//user/official_unbind_account', 'POST', {
					official_openid: this.official_openid
				});
				if (res.code == 1) {
					uni.showToast({
						title: '已解绑',
						duration: 2000
					});
					uni.removeStorageSync('official_openid');
					uni.removeStorageSync('username');
					setTimeout(() => {
						uni.redirectTo({
							url: "/pages/bindingOfficialAccount/bindingOfficialAccount"
						})
					}, 1500)
				}
			}
		}
	}
</script>

<style lang="scss">
	.bj {
		position: absolute;
		z-index: 1;
		top: -2600rpx;
		left: -1125rpx;
		width: 3000rpx;
		height: 3000rpx;
		border-radius: 3000rpx;
		background-color: #3488f7;
	}

	.main {
		position: relative;
		z-index: 10;
		padding: 60rpx 40rpx;
	}

	.nav1 {
		border-radius: 18rpx;
		background-color: #ffffff;
		text-align: center;
		padding: 60rpx 0;
		border: 1rpx solid #e4e7ed;

		.text1 {
			font-size: 42rpx;
			padding-top: 36rpx;
			font-weight: 500;
			color: #333333;
		}

		.text2 {
			font-weight: 400;
			font-size: 28rpx;
			padding-top: 36rpx;
			color: #606266;
		}

		.text3 {
			color: #3488f7;
			margin-top: 60rpx;
			font-size: 30rpx;
			width: 200rpx;
			margin: 60rpx auto 0;
		}
	}

	.logs {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 120rpx;
		box-sizing: border-box;

		image {
			width: 130rpx;
			height: 130rpx;
		}
	}
</style>